package com.groupbuying.store.dao.forManage;

import com.groupbuying.store.domain.forManage.TokenDO;
import org.apache.ibatis.annotations.*;

/**
 * @author ywxd
 * @version V1.0
 */
@Mapper
public interface TokenDao {
    /**
     * 根据用户id保存token
     * @param tokenDO
     * @return
     */
    @Insert("insert into  store_account_token (account_id,token,expire_time,update_time) values (#{accountId},#{token},#{expireTime},#{updateTime})")
    int save(TokenDO tokenDO);

    @Select("select * from store_account_token where token =#{token}")
    TokenDO getToken(String token);

    @Delete("delete from store_account_token where token=#{token}")
    boolean removeToken(String token);

    @Select("select * from store_account_token where account_id =#{accountId}")
    TokenDO getTokenByAccountId(String accountId);

    @Update("update store_account_token set token=#{token},expire_time=#{expireTime},update_time=#{updateTime} where account_id=#{accountId}")
    int update(TokenDO tokenDO);
}
